#ifndef  READSAVEXML_H
#define  READSAVEXML_H

#include <QObject>
#include <QVector>
#include <QString>
#include <QMap>
#include <QtXml/QDomDocument>

struct NodeXml
{
	QMap<QString, QString> mapAttr;
	QVector<NodeXml> vctNode;
	QString sValue;
	QString sName;

	NodeXml()
	{
		mapAttr.clear();
		vctNode.clear();
		sName = "";
		sValue = "";
	}

	NodeXml(QString Name, QString Value, QMap<QString, QString> attrMap, QVector<NodeXml> vctNodeXml)
	{
		sName = Name;
		sValue = Value;
		mapAttr = attrMap;
		vctNode = vctNodeXml;
	}

	NodeXml(QString Name, QString Value)
	{
		sValue = Value;
		sName = Name;
	}

	NodeXml(QString Name, QString Value, QMap<QString, QString> attrMap)
	{
		sName = Name;
		sValue = Value;
		mapAttr = attrMap;
	}

	NodeXml(QString Name, QString Value, QVector<NodeXml> vctNodeXml)
	{
		sName = Name;
		sValue = Value;
		vctNode = vctNodeXml;
	}

};

class ReadSaveXml :public QObject {
	 Q_OBJECT 
public:
    ReadSaveXml(QObject * parent = 0);
	~ReadSaveXml();

public slots:
    bool SaveXml(QString sPath, QVector<NodeXml> vctXml);
	void SaveXmlChild(QDomElement *pDomDocument, NodeXml nodeXml, QDomDocument doc);
	QVector<NodeXml> ReadXml(QString sPath);
	bool ReadXmlChild(QDomElement *pXmlElement, NodeXml &nodeXml);


private:
	bool QueryChild(const NodeXml &nodeXml, QString sName, NodeXml &resultXml);

};


#endif // ! READSAVEXML_H

